﻿--获取集团员工档案
CREATE PROCEDURE [dbo].[proc_Employee_GetGroupList]
(
	@startIndex int,
	@endIndex int,
	@docount bit,
	@searchTxt nvarchar(50)
)
as

set nocount on
	if(@docount=1)
		select *,'CompanyName'as CompanyName,'DepartmentName'as DepartmentName from employee 
	else
	begin
	declare @indextable table(id int identity(1,1),nid int)
	set rowcount @endIndex
	insert into @indextable(nid) select id from employee where 1=1 order by id asc
	select 
		 E.id
		,E.UserName
		,E.EName
		,E.Enumber
		,E.ETempNumber
		,E.Sex
		,E.CompanyId
		,(select companyname from company where id=E.CompanyId) as CompanyName
		,E.DepartmentId
		,(select dname from Department where id=E.DepartmentId) as DepartmentName
		,E.State
		,E.PostId
		,E.GradeId
		,E.WageNumber
		,E.RuzhiDate
		,E.LizhiDate
		,E.Birthday
		,E.Rtx
		,E.OfficePhone
		,E.HomePhone
		,E.MobilePhone
		,E.Email
		,E.IDcard
		,E.Address
		,E.Education
		,E.HeadPic
		,E.UpName
		,E.UpTime
	from employee E
	inner join @indextable t on 
	E.id=t.nid
	where 
		t.id between @startIndex and @endIndex 
	order by t.id
	end
set nocount off
RETURN